#include "Server.hpp"
#include <iostream>
#include <cstring>

void test_buffer()
{
    Buffer buf;
    const char* str = "hello world 1";
    buf.Write(str, strlen(str));

    char tmp[20] = { 0 };
    buf.Read(tmp, buf.ReadAbleSize());

    std::cout << tmp << std::endl;

    std::string stri;
    buf.ReadAsString(stri, buf.ReadAbleSize());
    std::cout << stri << std::endl;

    Buffer buffer;
    buffer.WriteBuffer(buf);
    buffer.ReadAndPop(tmp, buffer.ReadAbleSize());
    std::cout << tmp << std::endl;

    buffer.Clear();
    const char* str2 = "hello world1\nhaha";
    buffer.WriteString(str2);
    std::cout << buffer.GetLine() << std::endl;
    buffer.Clear();
    const char* str3 = "hello world2\r\nhaha";
    buffer.WriteString(str3);
    std::cout << buffer.GetLine() << std::endl;
}

void test_log()
{
    LOG(DEBUG, "HAHA");

    NRL_LOG("normal:%d", 1);
    DBG_LOG("debug:%d", 2);
    ERR_LOG("error:%d", 3);
}

int main()
{
    // test_log();
    test_buffer();

    return 0;
}